package com.douqu.game.rmi;

import com.douqu.game.core.rmi.MyRMISocket;
import com.douqu.game.core.util.LogUtils;

import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.RMISocketFactory;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-08-08 13:44
 */
public class RMIServer {

    public void start()
    {
        try {

            RMISocketFactory.setSocketFactory(new MyRMISocket());

            IRMI gameManager = new RMIImpl();

            LocateRegistry.createRegistry(1234);

            String url = "rmi://192.168.2.228:1234/Test";
            Naming.bind(url, gameManager);

            LogUtils.info("Start RMI Server Success ------ 【" + url + "】");

        } catch (Exception e) {
            LogUtils.error("创建远程对象发生异常！");
            e.printStackTrace();
        }
    }


    public static void main(String[] args) {
        new RMIServer().start();
    }
}
